﻿using ENMAX_ArcGIS;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Windows;
using ESRI.ArcGIS.Client.Geometry;

namespace ENMAX_ArcGIS_TestProject
{
    
    
    /// <summary>
    ///This is a test class for ArcGisMapTest and is intended
    ///to contain all ArcGisMapTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ArcGisMapTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for MapWidth
        ///</summary>
        [TestMethod()]
        public void MapWidthTest()
        {
            ArcGisMap target = new ArcGisMap();
            double expected = 200;
            double actual;
            target.MapWidth = expected;
            actual = target.MapWidth;
            Assert.AreEqual(expected, actual);            
        }

        /// <summary>
        ///A test for MapHeight
        ///</summary>
        [TestMethod()]
        public void MapHeightTest()
        {
            ArcGisMap target = new ArcGisMap();
            double expected = 150;
            double actual;
            target.MapHeight = expected;
            actual = target.MapHeight;
            Assert.AreEqual(expected, actual);            
        }

        /// <summary>
        ///A test for InitialExtent
        ///</summary>
        [TestMethod()]
        public void InitialExtentTest()
        {
            ArcGisMap target = new ArcGisMap();
            Envelope expected = new Envelope(-114.06, 51.05, -115, 51.5);
            Envelope actual;
            target.InitialExtent = expected;
            actual = target.InitialExtent;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for ZoomTo
        ///</summary>
        [TestMethod()]
        public void ZoomToTest()
        {
            ArcGisMap target = new ArcGisMap();
            Envelope geom = new Envelope(-114.06, 51.05, -115, 51.5);
            target.ZoomTo(geom);

            // use target.Extent to verify the correctness of this funtion
            Assert.AreEqual(target.InitialExtent, target.Extent);
            Assert.Inconclusive("Check map is loaded correctly first");
        }

        /// <summary>
        ///A test for Zoom
        ///</summary>
        [TestMethod()]
        public void ZoomTest()
        {
            ArcGisMap target = new ArcGisMap();
            double initialFactor = target.ZoomFactor;
            double factor = 1.5;
            target.Zoom(factor);

            // Check the new zoom factor
            double newFactor = target.ZoomFactor;
            
            Assert.AreEqual(initialFactor*factor, newFactor);
            Assert.Inconclusive("Check if the condition used is correct");
        }

        /// <summary>
        ///A test for setExtentFromLtdLng
        ///</summary>
        [TestMethod()]
        public void setExtentFromLtdLngTest()
        {
            ArcGisMap target = new ArcGisMap();
            double lat = 51.055149;
            double lng = -114.062438;
            target.setExtentFromLtdLng(lat, lng);

            // use target.Extent to verify the correctness of this funtion
            Assert.AreEqual(target.InitialExtent, target.Extent);
        }

        /// <summary>
        ///A test for ReloadMap
        ///</summary>
        [TestMethod()]
        public void ReloadMapTest()
        {
            ArcGisMap target = new ArcGisMap();            
            target.ReloadMap();

            // TODO
            Assert.Inconclusive("Check that the map is reloaded.");            
        }

        /// <summary>
        ///A test for PanTo
        ///</summary>
        [TestMethod()]
        public void PanToTest()
        {
            ArcGisMap target = new ArcGisMap();
            Point screenPoint = new Point(700, 190);
            target.PanTo(screenPoint);

            // TODO
            Assert.Inconclusive("Check the results of PanTo.");
        }

        /// <summary>
        ///A test for ArcGisMap Constructor
        ///</summary>
        [TestMethod()]
        public void ArcGisMapConstructorTest()
        {
            ArcGisMap target = new ArcGisMap();

            Assert.AreEqual(target.InitialExtent, target.Extent);
            
            Assert.Inconclusive("TODO: Implement code to verify target");
        }
    }
}
